package cn.springcloud.alibaba.admin.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@Slf4j
@RestController
public class HelloController {

	@Autowired
	private RestTemplate restTemplate;

	@GetMapping("/hello")
	public String hello() {
		String url = "http://localhost:8085/cms/hello";

		log.info("try http request");

		ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
		HttpStatus statusCode = responseEntity.getStatusCode();
		String body = responseEntity.getBody();

		// 返回
		return "response from jaeger-service-provider \nstatus : " + statusCode + "\nbody : " + body;
	}
}
